Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development


Field and widget lists

Application code often must identify and get the handles of the fields and other objects inside another object. This section describes some properties that give you that information.

DisplayedFields and FieldHandles

These CHARACTER properties are defined for Datavis objects, that is, SmartObjects that visualize data from a query (normally from an SDO). For a viewer, the DisplayedFields property returns a comma-separated list of all the fields in the viewer that come from the SDO, and the FieldHandles property returns the WIDGET-HANDLE of those fields. The fields can be any type that can display data, including FILL-IN, EDITOR, RADIO-SET, and so on.

The FieldHandles property returns a comma-separated list as well, with each handle converted to a text string. To retrieve the native handle from the list, you must apply the WIDGET-HANDLE 4GL function to the appropriate entry in the list. Both lists are always in the same order so that the standard way to get the handle of a field is to look it up in the DisplayedFields list and then locate the corresponding entry in the FieldHandles list. For example:

DEFINE VARIABLE cFields  AS CHARACTER  NO-UNDO. 
DEFINE VARIABLE cHandles AS CHARACTER  NO-UNDO. 
DEFINE VARIABLE iField   AS INTEGER    NO-UNDO. 
DEFINE VARIABLE hField   AS HANDLE     NO-UNDO. 
{get DisplayedFields cFields}. 
{get FieldHandles    cHandles}. 
iField = LOOKUP('Address', cFields). 
IF iField NE 0 THEN 
DO: 
    hField = WIDGET-HANDLE(ENTRY(iField, cHandles)). 
    MESSAGE hField:SCREEN-VALUE. 
END. 

This bit of code yields the display shown in Figure 5–1 at run time for the first Customer record.

Figure 5–1: Customer record message box

In the case of a SmartDataField in a viewer, which is a SmartObject procedure in its own right representing a single field value, the entry in FieldHandles is its procedure handle. The corresponding entry in the DisplayedFields list always points to the field name in the DataSource.

For example, code that manipulates the handle must always check the TYPE attribute, as shown:

DEFINE VARIABLE cFields  AS CHARACTER  NO-UNDO. 
DEFINE VARIABLE cHandles AS CHARACTER  NO-UNDO. 
DEFINE VARIABLE iField   AS INTEGER    NO-UNDO. 
DEFINE VARIABLE hField   AS HANDLE     NO-UNDO. 
{get DisplayedFields cFields}. 
{get FieldHandles    cHandles}. 
iField = LOOKUP('SalesRep', cFields). 
IF iField NE 0 THEN 
DO: 
    hField = WIDGET-HANDLE(ENTRY(iField, cHandles)). 
    IF hField:TYPE=’Procedure’ THEN 
        MESSAGE DYNAMIC-FUNCTION('getDataValue' IN hField). 
    ELSE MESSAGE hField:SCREEN-VALUE. 
END. 

The SmartDataField supports various internal functions that provide parallels to the properties of ordinary field-level widgets. For more information, see OpenEdge Development: ADM Reference .

For a browser, the DisplayedFields and FieldHandles properties return the list of columns in the browse itself and the handles to the browse cells for those columns.

EnabledFields and EnabledHandles

These two CHARACTER properties correspond to the DisplayedFields and FieldHandles properties, except that they return only fields or browse cells that are enabled for input.

AllFieldNames and AllFieldHandles

These CHARACTER properties, available for all visual objects (datavis class), return a list of all widgets in the SmartObject’s frame. This list includes the data fields that the DisplayedFields property returns as well as all other objects in the frame that are not derived from an SDO. For example, there might be non-SDO fields, along with field labels, rectangles, and buttons. Each of these is a separate widget with its own handle. For the SmartDataField, the procedure handle appears in the handle list.

These properties can be useful if you must manipulate objects in a viewer that are outside the standard field list, such as buttons. You can also use it for visual containers that have no SDO fields, such as a SmartWindow.

Currently, note that for browsers, these properties return the names and handles of the objects in the frame, not the columns in the browser. Thus, just a single name (brtable) comes back for the browse widget itself in the Names list, and its widget handle in the Handles list, along with the names and handles of any other objects that might be in the SmartBrowser’s frame along with the browse control. If you need the column list, you must use the DisplayedFields and FieldHandles properties.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095